# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: Andreas 'Segaja' Schleifer <segaja at archlinux dot org>

_gemname=thin
pkgname=ruby-${_gemname}
pkgver=1.8.1
pkgrel=1
pkgdesc='Thin and fast Ruby web server'
url='https://github.com/macournoyer/thin'
arch=('loong64' 'x86_64')
license=('RUBY')
depends=('glibc' 'ruby' 'ruby-rack' 'ruby-eventmachine' 'ruby-daemons')
makedepends=('ruby-rake')
checkdepends=('ruby-rake-compiler' 'ruby-rspec')
options=('!emptydirs')
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/macournoyer/thin/archive/v${pkgver}.tar.gz)
sha512sums=('221ef0c0369c449f2ca121c435ffebed318d6179a3b5d52e24d2bd80212df9cac35db39d156275c915c24550f6d8ded9f29616785d0a38e85cd13a1702e31298')
b2sums=('883a35d60d5845defa1f20a85b90269838a1b1ebeb4d4f32561af061cdac05b545c254fe65cca828ccfed033ad934ad3b72f1795407734d3b377a6022b57397f')

prepare() {
  cd ${_gemname}-${pkgver}
  sed -r 's|~>|>=|g' -i ${_gemname}.gemspec
}

build() {
  cd ${_gemname}-${pkgver}

  rake compile
  rake build
}

check() {
  cd "${_gemname}-${pkgver}"

  rake spec
}

package() {
  cd ${_gemname}-${pkgver}
  local _gemdir="$(gem env gemdir)"
  gem install --ignore-dependencies --no-user-install -i "${pkgdir}${_gemdir}" -n "${pkgdir}/usr/bin" ${_gemname}-${pkgver}.gem
  install -Dm 644 README.md CHANGELOG -t "${pkgdir}/usr/share/doc/${pkgname}"
  cp -a example "${pkgdir}/usr/share/doc/${pkgname}"
  rm "${pkgdir}/${_gemdir}/cache/${_gemname}-${pkgver}.gem" \
    "${pkgdir}/${_gemdir}/gems/${_gemname}-${pkgver}/ext/thin_parser/Makefile" \
    ${pkgdir}/${_gemdir}/gems/${_gemname}-${pkgver}/ext/thin_parser/*.o
  rm -rf "${pkgdir}/${_gemdir}/doc/${_gemname}-${pkgver}/ri/ext/"
  find "${pkgdir}/${_gemdir}" \( -name 'mkmf.log' -or -name 'gem_make.out' \) -delete
}

# vim: ts=2 sw=2 et:
